package com.zmj.modules.flow.client;

import com.zmj.framework.response.Result;
import com.zmj.modules.flow.client.fallback.FlowableClientFallback;
import com.zmj.modules.flow.entity.dto.BpmProcessQueryDto;
import com.zmj.modules.flow.entity.dto.BpmProcessStartQueryDto;
import com.zmj.modules.flow.entity.dto.BpmTaskAssigneeDTO;
import com.zmj.modules.flow.entity.dto.BpmTaskBackQueryDTO;
import com.zmj.modules.flow.entity.dto.BpmTaskCcQueryDto;
import com.zmj.modules.flow.entity.dto.BpmTaskFinishQuery;
import com.zmj.modules.flow.entity.dto.BpmTaskQueryDto;
import com.zmj.modules.flow.entity.vo.ProcessInstanceVO;
import com.zmj.modules.flow.entity.vo.TaskAssigneeVO;
import com.zmj.modules.flow.entity.vo.TaskBackVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 杨俊辰
 */
@FeignClient(name = "flowable", url = "${feign.client.urls.flowUrl}", fallback = FlowableClientFallback.class)
public interface FlowableClient {


    /**
     * 查询全部代办任务
     *
     * @param bpmProcessQueryDto
     * @return
     */
    @PostMapping("/task/getAllTodoTasks")
    Result getAllTodoTasks(@RequestBody BpmTaskCcQueryDto bpmProcessQueryDto);


    /**
     * 查询代办任务
     *
     * @param bpmProcessQueryDto
     * @return
     */
    @PostMapping("/task/getTodoTasks")
    Result getTodoTasks(@RequestBody BpmTaskCcQueryDto bpmProcessQueryDto);

    /**
     * 抄送代办列表
     *
     * @param bpmProcessQueryDto
     * @return
     */
    @PostMapping("/task/ccTaskList")
    Result ccTaskList(@RequestBody BpmTaskCcQueryDto bpmProcessQueryDto);

    /**
     * 抄送代办列表
     *
     * @param bpmTaskFinishQuery
     * @return
     */
    @PostMapping("/task/getFinishTasks")
    Result getFinishTasks(@RequestBody BpmTaskFinishQuery bpmTaskFinishQuery);

    /**
     * 获取流程模型列表
     *
     * @param bpmProcessQueryDto 请求参数
     * @return 流程集合
     */
    @PostMapping("/process/getProcessModels")
    Result getProcessModels(BpmProcessQueryDto bpmProcessQueryDto);

    /**
     * 流程发起
     *
     * @param bpmProcessStartQueryDto 请求参数
     * @return 获取流程下一部的信息及本步骤操作时的记录
     */
    @PostMapping("/process/startProcessInstance")
    Result<ProcessInstanceVO> startProcessInstance(@RequestBody BpmProcessStartQueryDto bpmProcessStartQueryDto);

    /**
     * 流程处理
     *
     * @param bpmTaskQueryDto taskId	任务id
     *                        variables	相关变量
     *                        comment	审核意见
     * @return 获取流程下一部的信息及本步骤操作时的记录
     */
    @PostMapping("/task/handle")
    Result handle(@RequestBody BpmTaskQueryDto bpmTaskQueryDto);

    /**
     * 结束流程
     *
     * @param taskId  任务ID
     * @param comment 备注
     * @return 结果
     */
    @GetMapping("/process/stopProcessInstance")
    Result stopProcessInstance(@RequestParam("taskId") String taskId,
                               @RequestParam("comment") String comment);

    /**
     * 结束流程
     *
     * @return 结果
     */
    @PostMapping("/task/back")
    Result<TaskBackVO> taskBack(@RequestBody BpmTaskBackQueryDTO bpmTaskBackQueryDTO);

    /**
     * 查询当前任务办理人
     */
    @PostMapping("/task/getTaskAssignee")
    Result<List<TaskAssigneeVO>> getTaskAssignee(@RequestBody BpmTaskAssigneeDTO bpmTaskAssigneeDTO);

    @PostMapping("/process/getAllProcessInstance")
    Result getAllProcessInstance(@RequestBody BpmTaskFinishQuery bpmTaskFinishQuery);
}
